{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-0.0212915  -0.04916746]\n",
      " [-0.03578652  0.0301427 ]\n",
      " [ 0.00973498  0.00815342]\n",
      " ...\n",
      " [ 0.03212571  0.00198904]\n",
      " [ 0.01000712  0.01401358]\n",
      " [-0.03510248 -0.03105836]]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.datasets import samples_generator\n",
    "from sklearn.manifold import LocallyLinearEmbedding\n",
    "\n",
    "\n",
    "data, color = samples_generator.make_swiss_roll(n_samples=1500)\n",
    "n_neighbors = 12 # 近邻点的数量\n",
    "n_components = 2 # 降维后的维度\n",
    "model = LocallyLinearEmbedding(n_neighbors=n_neighbors,\n",
    "n_components=n_components)\n",
    "model.fit(data)\n",
    "print(model.transform(data)) # 变换后的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
